<?php
/**
 * 
 * @authors Your Name (you@example.org)
 * @date    2018-12-06 15:43:07
 * @version $Id$
 */



include "dataConfig.php";

if($_SERVER["REQUEST_METHOD"] == "POST"){
    if(isset($_POST["uname"]) && isset($_POST["upwd"])){
        session_start();
        sleep(1.8);
        $uname = $_POST["uname"];
        $upwd = $_POST["upwd"];

        $sql = "SELECT  `uid`,`uname`,`urelname`,`ugender`,`utel`,`uemail`,`uimg`  FROM userinfo WHERE uname=? AND upwd=? ";

        $stmt = $conn->prepare($sql);

        $stmt->bind_param("ss", $uname, $upwd);

        $stmt->execute();
        $result = $stmt->get_result();
        if($result->num_rows>=1){
            $userInfo=array();  
            while($item=$result->fetch_assoc()){ 
                $_SESSION["uid"]=$item['uid'];
                array_push($userInfo,$item);
            } 
            print_r(json_encode(array("status"=>1,"msg"=>"登录成功","data"=>$userInfo)));
        }else{
            print_r(json_encode(array("status"=>0,"msg"=>"用户名或密码错误")));
        }

    }

}else{
    print_r(json_encode(array("status"=>-1,"msg"=>"不支持get")));
}